import 'package:flutter/services.dart';

class CheckAppInstall {
  final methodChannel = const MethodChannel('com.chentianle/check_app_install');

  /// 获取APP是否安装
  /// uri:only ios Schemes xxxxx://com.chentianle
  /// packageName:only android 包名
  /// 在Info.plist文件里,找到LSApplicationQueriesSchemes,添加对应APP的Schemes
  /// Andorid 需要添加 <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
  Future<bool?> checkIsInstallApp({
    String? uri,
    String? packageName,
  }) async {
    return await methodChannel.invokeMethod<bool?>(
        'checkIsInstallApp', {'uri': uri, 'packageName': packageName});
  }

  /// 打开其他APP
  /// uri: Schemes xxxxx://com.chentianle
  Future<bool?> openOtherApp({
    String? uri,
  }) async {
    return await methodChannel.invokeMethod<bool?>(
        'openOtherApp', {'uri': uri});
  }
}
